package com.wave.spring.web.controller;

import jmind.base.util.DataUtil;
import jmind.base.util.DateUtil;
import jmind.base.util.RandUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;

import java.util.Date;

/**
 * Created by lv on 2017/8/26.
 */
@RestController
public class AysncController {

    private DeferredResult<String> deferredResult=new DeferredResult<>();
    @Scheduled(fixedDelay = 3000)
    public void refresh(){
        deferredResult.setResult(RandUtil.randomCode(8)+",time="+ DateUtil.format(new Date(),DateUtil.F24_PATTERN));
    }

    public DeferredResult<String> deferredCall(){
        return deferredResult;
    }
}
